package com.chixing.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.chixing.commons.ServerResponse;
import com.chixing.pojo.CompanyDetail;
import com.chixing.pojo.EducationalExperience;
import com.chixing.pojo.Myresume;
import com.chixing.mapper.MyresumeMapper;
import com.chixing.service.IMyresumeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 简历表 服务实现类
 * </p>
 *
 * @author Jason Marslyon
 * @since 2022-10-04
 */
@Service
public class MyresumeServiceImpl  implements IMyresumeService {
    @Autowired(required = false)
    private MyresumeMapper myresumeMapper;

    //    根据用户id获得其他信息
    @Override
    public Myresume getAllById(Integer personId) {
        QueryWrapper wrapper = new QueryWrapper<>();
        wrapper.eq("person_id", personId);
        List<Myresume> list = myresumeMapper.selectList(wrapper);
        if(list.size() == 0){
            return null;
        }
        return list.get(0);
//        根据id的查询结果放入list集合
//        QueryWrapper<Myresume> wrapper = new QueryWrapper<>();
//        wrapper.eq("person_id",personId);
//        Myresume myresume = myresumeMapper.selectOne(wrapper);
//        System.out.println(myresume+"wwwwwwwwwmyresumeServicewwwwwwwwwwwwwwww");
//        return myresume;


    }

    @Override
    public ServerResponse updateMyresumer(Myresume myresume, Integer myresumeId) {
        Myresume myresumeSql = myresumeMapper.selectById(myresumeId);

        myresumeSql.setPersonalAdvantages(myresume.getPersonalAdvantages());
        myresumeSql.setExpectedPosition(myresume.getExpectedPosition());
        myresumeSql.setExpectedIndustry(myresume.getExpectedIndustry());
        myresumeSql.setExpectationSalaryMin(myresume.getExpectationSalaryMin());
        myresumeSql.setExpectationSalaryMax(myresume.getExpectationSalaryMax());
        myresumeSql.setWorkArea(myresume.getWorkArea());
        myresumeSql.setMyresumeTel(myresume.getMyresumeTel());
        myresumeSql.setMyresumeEmail(myresume.getMyresumeEmail());
        myresumeSql.setTest1(myresume.getTest1());//个人优势

        int myresumeUpdate = myresumeMapper.updateById(myresumeSql);
        if (myresumeUpdate > 0) {
            return ServerResponse.success("myresume表修改成功", null);
        }
        return ServerResponse.fail("myresume表修改失败", null);
    }


    @Override
    public ServerResponse getById(Integer myresumeId) {
        Myresume myresume = myresumeMapper.selectById(myresumeId);
        if (myresume == null) {
            return ServerResponse.fail("myresume查询失败", null);
        } else {
            return ServerResponse.success("myresume查询成功", myresume);
        }
    }

    @Override
    public ServerResponse save(Myresume myresume) {
        return null;
    }

    @Override
    public ServerResponse update(Myresume myresume) {
        return null;
    }


    @Override
    public ServerResponse delete(Integer myresumeId) {
        return null;
    }
}